#pragma once

#include "fxcc/core/pch.h"
#include "fxcc/core/Dir.h"

struct MetaIndex
{
	std::string m_FilePath;
	uint64_t m_LastUpdateTime;
};

struct MetaMapIndex
{
	std::string m_NativeFile{};
	std::string m_TargetFile{};
	std::string m_TargetDir{};
	std::string m_TargetFilePath{};
	std::string m_GUID{};
	std::string m_FileId{};
	std::string m_Name{};
	std::string m_Seed{};

	bool operator==(const MetaMapIndex& other) const {
		return m_TargetFilePath == other.m_TargetFilePath;
	}
	bool operator!=(const MetaMapIndex& other) const {
		return m_TargetFilePath != other.m_TargetFilePath;
	}

	void SetTexture2D(const std::string& _P)
	{

	}
	void SetTextureHDR(const std::string& _P)
	{

	}
	void SetFrag(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::FragSuffix()[0]);
	}
	void SetDll(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::DLLSuffix()[0]);
	}
	void SetMesh(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::MeshSuffix()[0]);
	}
	void SetSkinned(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::SkinnedSuffix()[0]);
	}
	void SetBone(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::BonesSuffix()[0]);
	}
	void SetAnimation(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::AnimSuffix()[0]);
	}

	void SetPrefeb(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::PrefebSuffix()[0]);
	}
	void SetMaterial(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::MaterialSuffix()[0]);
	}
	void SetRealMaterial(const std::string& targetDir, const std::string& nativePath, int index)
	{
		const std::string suffix = fxcc::FileUtil::RealMaterialSuffix()[0];
		SetNativePath(nativePath);

		m_TargetDir = targetDir;
		m_Seed = std::to_string(index);
		//m_FileId = fxcc::FileUtil::getTargetUUID(nativePath, m_Seed);
		m_FileId = m_Name;
		m_TargetFile = m_FileId + suffix;
		m_TargetFilePath = (fs::path(m_TargetDir) / fs::path(m_TargetFile)).string();
	}
	void SetAudio(const std::string& targetDir, const std::string& nativePath, int index)
	{
		SetTargetFile(targetDir, nativePath, std::to_string(index), fxcc::FileUtil::OggSuffix()[0]);
	}
	void SetNativePath(const std::string& f) {
		m_NativeFile = f;
		m_GUID = fxcc::FileUtil::getTargetPath(f);
	}

	void SetTargetFile(const std::string& dir, const std::string& nativeFilePath, const std::string& seed, const std::string& suffix)
	{
		SetNativePath(nativeFilePath);
		m_TargetDir = dir;
		m_Seed = seed;
		m_FileId = fxcc::FileUtil::getTargetUUID(nativeFilePath, m_Seed);
		//m_TargetFile = fxcc::FileUtil::GetFileNameWithoutRepeat(dir, m_FileId, suffix);
		//m_TargetFilePath = fxcc::FileUtil::GetFileWithoutRepeat(dir, m_FileId, suffix);
		m_TargetFile = m_FileId + suffix;
		m_TargetFilePath = (fs::path(m_TargetDir) / fs::path(m_TargetFile)).string();
	}

	void SetName(const std::string& name)
	{
		m_Name = name;
	}
};

struct MetaCache
{
	std::vector<MetaMapIndex> m_MetaMapIndexes;
};




